#include <string.h>

int check_for_file_type(char *fileName)
{
	char str[20];
	strcpy(str,fileName);
	char delim[] = ".";
	char *result = NULL;
	char *prevResult = NULL;
	result = strtok(str,delim);
	
	//get the extension from file name and store it at prevResult
	while(result != NULL)
	{
		prevResult = result;
		result = strtok(NULL,delim);
	}
	//printf("%s\n",prevResult);

	//Check for extension
	if(strcmp(prevResult,"html") == 0 || strcmp(prevResult,"php") == 0 || strcmp(prevResult,"js") == 0 || strcmp(prevResult,"asp") == 0 || strcmp(prevResult,"css") == 0 || strcmp(prevResult,"jsp") == 0)
		return 1;
	else
		return 0;
}

int main()
{
	int ret = check_for_file_type("pdd.asp.doc.pdf");
	if(ret == 0)
		printf("Attempt to open non-web file!\n");
	return 0;
}
